package org.luckystrophe.snowtoms;

import android.content.Intent;
import android.text.method.ScrollingMovementMethod;
import android.view.KeyEvent;
import android.widget.ImageView;
import android.widget.TextView;

import com.actionbarsherlock.app.SherlockActivity;
import com.androidquery.AQuery;
import com.googlecode.androidannotations.annotations.AfterInject;
import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.EActivity;
import com.googlecode.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_fullsizeimage)
public class FullsizeImageActivity extends SherlockActivity {

	@ViewById(R.id.iv_originalSize)
	ImageView iv_originalSize;

	@ViewById(R.id.tv_fullsizecomment)
	TextView tv_fullSizeComment;

	// @ViewById(R.id.tv_fullsizelocation)
	// TextView tv_fullSizeLocation;

	AQuery aq;

	@AfterInject
	public void afterInject() {
		aq = new AQuery(this);
	}

	@AfterViews
	public void afterView() {
		Intent i = getIntent();
		String imageUrl = i.getStringExtra("imageSrc");
		String comment = i.getStringExtra("comment");
		// String location = i.getStringExtra("location");

		tv_fullSizeComment.setMovementMethod(ScrollingMovementMethod.getInstance());
		aq.id(iv_originalSize).image(imageUrl);
		tv_fullSizeComment.setText(comment);
		// tv_fullSizeLocation.setText("#" + location);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			finishActivity();
		}
		return super.onKeyDown(keyCode, event);
	}

	private void finishActivity() {
		finish();
		overridePendingTransition(R.anim.fadein, R.anim.deltahundred);
	}

}
